package org.xx.armory.swing.builders;

import java.util.ArrayList;
import java.util.List;

public class DropDownModelBuilder
        extends ComponentModelBuilder<DropDownModel>
        implements OptionsContainerBuilder {
    private boolean includeAll;
    private boolean includeNone;
    private boolean simple;
    private int size;
    private boolean required;
    private String optionsName;
    private List<OptionModel> options;

    public DropDownModelBuilder() {
        this.options = new ArrayList<>();
    }

    public DropDownModelBuilder setIncludeAll(
            boolean includeAll
    ) {
        this.includeAll = includeAll;
        return this;
    }

    public DropDownModelBuilder setIncludeNone(
            boolean includeNone
    ) {
        this.includeNone = includeNone;
        return this;
    }

    public DropDownModelBuilder setSimple(
            boolean simple
    ) {
        this.simple = simple;
        return this;
    }

    public DropDownModelBuilder setSize(
            int size
    ) {
        this.size = size;
        return this;
    }

    public DropDownModelBuilder setRequired(
            boolean required
    ) {
        this.required = required;
        return this;
    }

    public DropDownModelBuilder setOptionsName(
            String optionsName
    ) {
        this.optionsName = optionsName;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void addOption(
            OptionModel option
    ) {
        this.options.add(option);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public DropDownModel build() {
        return new DropDownModel(getLineInfo(), getName(), isVisible(), this.includeAll, this.includeNone, this.simple, this.size, this.required, this.optionsName, this.options);
    }
}
